//
//  User.swift
//  HYYWeibo
//
//  Created by HY-Mac on 16/7/16.
//  Copyright © 2016年 HY-Mac. All rights reserved.
//

import UIKit

class User: NSObject {
    /// 字符串型的用户UID
    var idstr: String?
    
    /// 用户昵称
    var screen_name: String?
    
  
    
    /// 用户头像地址（中图），50×50像素
    var profile_image_url: String?{
        didSet{
            icon_URL = NSURL(string: profile_image_url!)
        }
    }
    var icon_URL: NSURL?
    /// 用户认证类型
    /// 用户认证类型 -1：没有认证，0，认证用户，2,3,5: 企业认证，220: 达人
    var verified_type: Int = -1{
        didSet{
            switch verified_type {
            case 0: verified_image = UIImage(named: "avatar_vip")
            case 2,3,5: verified_image = UIImage(named: "avatar_enterprise_vip")
            case 220: verified_image = UIImage(named: "avatar_grassroot")
            default: verified_image = nil
            }
        }
    }
    
    ///用户认证图片
    var verified_image: UIImage?
    
    /// 会员等级 ,取值范围 1~6
    var mbrank: Int = -1{
        didSet{
            if mbrank >= 1 && mbrank <= 6
            {
                mbrankImage = UIImage(named: "common_icon_membership_level\(mbrank)")!
            }
        }
    }
    
    var mbrankImage: UIImage?
    
    init(dict: [String: AnyObject])
    {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    override var description: String {
        let property = ["idstr", "screen_name", "profile_image_url", "verified_type"]
        let dict = dictionaryWithValuesForKeys(property)
        return "\(dict)"
    }


}
